package org.example.taxi.controller;

import org.example.taxi.service.HiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/")
public class HiveController {

    @Autowired
    private HiveService hiveService;

    /**
     * 执行查询接口
     *
     * @param table SQL 语句（注意：生产环境应避免直接传递 SQL，存在 SQL 注入风险）
     * @return 查询结果
     */
    @GetMapping("/query")
    public List<Map<String, Object>> queryHive(@RequestParam String table) {
        // 注意：直接通过参数传递 SQL 存在安全风险，建议在生产环境中限制可执行的 SQL 或使用参数化查询
        return this.hiveService.executeQuery(table);
    }

    @GetMapping("/chart2")
    public Map<String, List<Object>> chart2() {
        return this.hiveService.chart2();
    }

    @GetMapping("/chart3")
    public List<Map<String, Object>> chart3() {
        return this.hiveService.chart3();
    }

    @GetMapping("/chart4")
    public List<Map<String, Object>> chart4() {
        return this.hiveService.chart4();
    }

    @GetMapping("/chart5")
    public List<Map<String, Object>> chart5() {
        return this.hiveService.chart5();
    }

    @GetMapping("/chart6")
    public Map<String, List<Object>> chart6() {
        return this.hiveService.chart6();
    }

    @GetMapping("/chart7")
    public Map<String, List<Object>> chart7() {
        return this.hiveService.chart7();
    }

    @GetMapping("/chart8")
    public List<Map<String, Object>> chart8() {
        return this.hiveService.chart8();
    }

    @GetMapping("/chart9")
    public Map<String, List<Object>> chart9() {
        return this.hiveService.chart9();
    }

    @GetMapping("/chart10")
    public Map<String, List<Object>> chart10() {
        return this.hiveService.chart10();
    }

    @GetMapping("/chart11")
    public Map<String, List<Object>> chart11() {
        return this.hiveService.chart11();
    }

    @GetMapping("/chart12")
    public Map<String, Map<String, List<Object>>> chart12() {
        return this.hiveService.chart12();
    }
}